package com.algorithm.base.greedy;

/**
 * 122. 买卖股票的最佳时机 II
 *
 * @author Amadeus
 * @date 2023/11/20
 */
public class MaxProfit {

    public int maxProfit(int[] prices) {
        int result = 0;
        for (int i = 0; i < prices.length - 1; i++) {
            if (prices[i + 1] > prices[i]) {
                result += prices[i + 1] - prices[i];
            }
        }
        return result;
    }

}
